<template>
  <!--  如果goods不为空-->
  <div v-if="Object.keys(goods).length !== 0" class="base-info">
    <div class="info-title">{{ goods.title }}</div>

    <div class="info-price">
      <span class="n-price">{{ goods.newPrice }}</span>
      <span class="o-price">{{ goods.oldPrice }}</span>
      <span v-if="goods.discount" class="discount">{{ goods.discount }}</span>
    </div>

    <div class="info-other">
      <span>{{ goods.columns[0] }}</span>
      <span>{{ goods.columns[1] }}</span>
      <span>{{ goods.services[goods.services.length - 1].name }}</span>
    </div>

    <div class="info-service">
      <span class="info-service-item"
            v-for="index in goods.services.length-1"
            :key="index">
        <!--前面已经取过了不用再取了 ↑-->
        <!--v-for遍历数字 是从1开始 ↓-->
        <img :src="goods.services[index-1].icon" alt="">
        <span>{{ goods.services[index-1].name }}</span>
      </span>
    </div>

  </div>
</template>


<script>
export default {
  name: "DetailBaseInfo",
  props: {
    goods: {
      type: Object,
      default() {
        return {};
      }
    }
  }
}
</script>

<style scoped>
.base-info {
  color: #999;
  border-bottom: 5px solid #f2f5f8;
  margin-top: 15px;
  padding: 6px;
}

.info-title {
  color: #222;
  text-align: justify;
  letter-spacing: 1px;
  line-height: 21px;
}

.info-price {
  margin-top: 6px;
}

.info-price .n-price {
  color: var(--color-high-text);
  font-size: 24px;
  font-weight: bold;
}

.info-price .o-price {
  font-size: 14px;
  margin-left: 4px;
  text-decoration: line-through;
}

.info-price .discount {
  font-size: 12px;
  color: #fff;
  background-color: var(--color-high-text);
  border-radius: 8px;
  padding: 2px 5px;
  margin-left: 5px;
  /*相对上移一些*/
  position: relative;
  top: -10px;
}

.info-other {
  padding: 8px 0;
  /*margin-top: 10px;*/
  line-height: 30px;
  font-size: 13px;
  border-bottom: 1px solid rgba(100, 100, 100, .1);

  /*这两个样式是组合发挥作用的*/
  /*justify-content: 如何分配顺着弹性容器主轴的元素之间及其周围的空间*/
  /*space-between: 均匀排列每个元素,每个元素周围分配相同的空间*/
  display: flex;
  justify-content: space-between;
}

.info-service {
  display: flex;
  justify-content: space-between;
}

.info-service-item img {
  height: 14px;
  width: 14px;
  margin-right: 3px;

  position: relative;
  top: 2px;
}

.info-service-item span {
  font-size: 13px;
  color: #333;
  line-height: 55px;
}
</style>
